// SETUP

#include endepisodegraphics_ladyluck.txt

// HELPER FUNCTIONS	

function signanimate(sign) {
	var s = sign.show("turn");
	//s.onComplete(function() { resume(); sign.show("loop"); });
	//pause();
	while(!s.completed) {
		// do nothing
	}
	sign.show("loop");
}

function spinthewheel(sign, wheel) {
  var s = sign.show("turn");
	//s.onComplete(function() { resume(); sign.show("loop"); });
	//pause();
	while(!s.completed) {
		// do nothing
	}
	sign.hide();
	
  wheel.x = 30;
  wheel.y = -30;
  play("spinthewheel");
	var s = wheel.show("spin1");
	//s.onComplete(function() { resume(); sign.show("loop"); });
	//pause();
	while(!s.completed) {
		// do nothing
	}
	wheel.hide();
}

// ACTORS
//actor("Lady Luck", screenwidthmid + 800, 550, Col.YELLOW, CENTER, BOTTOM, "chat_ladyluck", "characters/misc/charicon_ladyluck");
//actor("Jester", 2600, 600, 0xb496ec, RIGHT, TOP, "chat_jester", "characters/jester/charicon_jester");
actor("Lady Luck", screenwidthmid + 400, 100, Col.YELLOW, LEFT, TOP, "chat_ladyluck", "characters/misc/charicon_ladyluck");
actor("Jester", 150, screenheight - 100, Col.multiplylightness(Col.RED, 1.25), LEFT, BOTTOM, "chat_jester", "characters/jester/charicon_jester");
// INTRO

play("music_cutscene_lesscheery");

changebackground("intro_sign");

sign.y = -screenheight;
ladyluck_sign.y = -screenheight;
sign.show("loop");
ladyluck_sign.show("idle");

Actuate.tween(sign, 2, { y: 0 }).ease(Expo.easeOut);
Actuate.tween(ladyluck_sign, 2, { y: 0 }).ease(Expo.easeOut);

wait(0.5);

fadein();

wait(1.5);

ladyluck_sign.show("talking");
actor("Lady Luck", screenwidthmid + 200, 100, Col.YELLOW, LEFT, TOP, "chat_ladyluck", "characters/misc/charicon_ladyluck");
speak("Lady Luck", "Ah, my little betrayer of trust! It’s you!");
ladyluck_sign.show("idle");

speak("Jester", "Yep, it’s me!");

ladyluck_sign.show("talking");
actor("Lady Luck", screenwidthmid + 200, 100, Col.YELLOW, LEFT, TOP, "chat_ladyluck", "characters/misc/charicon_ladyluck");
speak("Lady Luck", "How does it feel to be on the other|side of the wheel?");
ladyluck_sign.show("idle");

speak("Jester", "Pretty good, actually!");

ladyluck_sign.show("talking");
actor("Lady Luck", screenwidthmid + 400, 100, Col.YELLOW, LEFT, TOP, "chat_ladyluck", "characters/misc/charicon_ladyluck");
speak("Lady Luck", "...really?");
actor("Lady Luck", screenwidthmid + 300, 100, Col.YELLOW, LEFT, TOP, "chat_ladyluck", "characters/misc/charicon_ladyluck");
speak("Lady Luck", "After all these hundreds of years of|spinning the wheel...");
speak("Lady Luck", "...even you must realise it’s not|going to land on a prize.");
ladyluck_sign.show("idle");

speak("Jester", "I mean, that’s not ideal, but you know what?");
speak("Jester", "Better to be cheated than to be a cheat!");

ladyluck_sign.show("talking");
actor("Lady Luck", screenwidthmid + 100, 100, Col.YELLOW, LEFT, TOP, "chat_ladyluck", "characters/misc/charicon_ladyluck");
speak("Lady Luck", "...well, let’s go through the motions.");
ladyluck_sign.show("idle");

ladyluck_sign.hide();

spinthewheel(sign, wheel);

signanimate(sign);

ladyluck_sign.show("talking");
actor("Lady Luck", screenwidthmid + 300, 100, Col.YELLOW, LEFT, TOP, "chat_ladyluck", "characters/misc/charicon_ladyluck");
speak("Lady Luck", "Will you have a look at that! You lose.");
ladyluck_sign.show("idle");

speak("Jester", "Guess I’ll just have to go and fight in another episode, then.");
speak("Jester", "At least I know I’m on the right side now!");

ladyluck_sign.show("talking");
actor("Lady Luck", screenwidthmid + 400, 100, Col.YELLOW, LEFT, TOP, "chat_ladyluck", "characters/misc/charicon_ladyluck");
speak("Lady Luck", "See you soon, minion.");
speak("Lady Luck", "And for eternity.");
ladyluck_sign.show("idle");

gamecompletefromcutscene();
